<%--
  Created by IntelliJ IDEA.
  User: zhangyading
  Date: 2021/7/28
  Time: 1:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>登录界面</title>
  </head>
  <body>
  <%
    String name = "";
    String psw = "";
    //读取cookie
    Cookie[] cookies = request.getCookies ();
    if (cookies != null) {
      for (int i=0;i<cookies.length;i++) {
        if (cookies[i].getName ().equals ("username")) {
            name = cookies[i].getValue ();
        }
        if (cookies[i].getName ().equals ("password")) {
          psw = cookies[i].getValue ();
        }
      }
      if (name.equals ("admin")&&psw.equals ("123456")) {
        //用户登录过改网站直接登录
        request.getRequestDispatcher ("guanli.jsp").forward (request,response);
      }
    }
  %>
  <form action="login1" method="post">
    用户账号:<input type="text" name="userName"/><br/>
    密&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp码:<input type="text" name="passWord"/><br/>
    <span style="color: red"><%=request.getAttribute("error")==null?"":request.getAttribute("error")%></span><br/>
    <input type="checkbox" name="login_auto">自动登录<br/>
    <input type="submit" value="提交"/>
  </form>
  </body>
</html>

